package com.geezdata.cps.base.exceptions.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * 第一步：定义符合线程异常处理器规范的“异常处理器”
 * 实现Thread.UncaughtExceptionHandler规范
 */
public class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
	
	private static Logger logger = LoggerFactory.getLogger(MyUncaughtExceptionHandler.class);
    /*
     * Thread.UncaughtExceptionHandler.uncaughtException()会在线程因未捕获的异常而临近死亡时被调用
     */
    @Override
    public void uncaughtException(Thread t, Throwable e) {
    	e.printStackTrace();
    	logger.error(e.getMessage(), e);
    }
}